import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import NetworkSettings from '../views/NetworkSettings.vue'
import RemoteControl from '../views/RemoteControl.vue'
import MecanumWheel from '../views/MecanumWheel.vue'
import Control from '../views/Control.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: { title: '智能小车控制系统' }
  },
  {
    path: '/network-settings',
    name: 'NetworkSettings',
    component: NetworkSettings,
    meta: { title: '网络设置' }
  },
  {
    path: '/remote-control',
    name: 'RemoteControl',
    component: RemoteControl,
    meta: { title: '遥控控制' }
  },
  {
    path: '/control',
    name: 'Control',
    component: Control,
    meta: { title: '控制小车' }
  },
  {
    path: '/mecanum-wheel',
    name: 'MecanumWheel',
    component: MecanumWheel,
    meta: { title: '麦克纳姆轮控制' }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

// 路由守卫，设置页面标题
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router 